import {
  setToastDefaultOptions,
  showSuccessToast,
  showFailToast,
  showLoadingToast,
  closeToast,
  showToast,
} from 'vant';

// 将所有 Toast 的展示时长设置为 2000 毫秒
setToastDefaultOptions({
  duration: 2000,
});

// 将所有 loading Toast 设置为背景不可点击
setToastDefaultOptions('loading', {
  duration: 0,
  forbidClick: true,
});

// 重置所有 Toast 的默认配置
// Toast.resetDefaultOptions();

// 重置 loading Toast 的默认配置
// Toast.resetDefaultOptions('loading');

export function success(msg) {
  return showSuccessToast(msg);
}

export function error(msg) {
  return showFailToast(msg);
}

export function loading(msg) {
  return showLoadingToast({
    message: msg || '加载中...',
  });
}

export function clear() {
  return closeToast();
}

export function message(options) {
  return showToast(options);
}
